﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T06ArrayType
{
    class Program
    {
        static void Main(string[] args)
        {
            //一维数组
            #region
            int[] array1 = new int[10];
            int[] array2 = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            for (int j = 0; j < array1.Length; j++)
            { array1[j] = (j + 1) * 10; }
            foreach (int _x in array2)
            { Console.WriteLine($"{_x }\t"); }
            Console.WriteLine("==========一维数组==========");
            #endregion

            //Array 类
            #region
            //System.Array的使用  拆箱装箱
            Console.WriteLine(array1 .Max ());
            Console.WriteLine(array1 .Min ());
            array1.Reverse();
                foreach (int _x in array2)
            { Console.WriteLine($"{_x }\t"); }
            Console.WriteLine("=========Array包装类=========");
            Console.WriteLine();
            #endregion
            #region 多维数组
            int[,] array3 = new int[3, 4];
            int[,,] array4 = new int[3, 4, 5];
            for (int i = 0; i < array3.GetLength(0); i++)
            {
                for (int j = 0; j < array3.GetLength(1); j++)
                {
                    array3[i, j] = (i + 1) * (j + 1);
                    Console.WriteLine($"{array3 [i,j]}\t");

                }
                
            }
            Console.WriteLine("=========多维数组=========");
            #endregion

            #region  数组的数组
            int[][] array5 = new int[3][];//具有三个数组元素的数组
            //初始化
            //for(int i=0;i<3;i++)
            // {array5[i]=new int[4];}
            //创建每个数组元素为四个元素的数组
            array5[0] = new int[2] { 1, 2 };
            array5[1] = new int[3] { 3,4,5 };
            array5[2] = new int[4] { 6,7,8,9};
            foreach (int[] arr in array5)
            {
                foreach (int _x in arr)
                {
                    Console.WriteLine($"{_x }\t");
                }
            }
            Console.WriteLine("=========数组的数组=========");
            //CTRL+M,M折叠代码
            //CTRL+K,C添加行注释
            //CTRL+K,U取消行注释  
            //CTRL+K,D格式化代码

            #endregion

            Console.ReadKey();
        }
    }
}
